<?php

class AdvController extends My_Controller_Action {

    public function gotoAction() {
        $code = $this->_getParam('id');
        $daoAdv = new Application_Model_DAO_Adv();
        $adv = $daoAdv->getByCode($code);
        if(empty($adv)) {
            $this->addError($this->translate('XXX_ADV_GOTO_ADV_NOT_EXIST'));
            $this->_redirect('/');
        }
        $url = $adv['url'];
        if(!empty($url)) {
            $daoAdv->increase($adv['adv_id'], 'click_cnt');
        }
        $this->_redirect($url);
    }

}

